<?php
/**
 * Created by PhpStorm.
 * User: FDG296
 * Date: 2017/8/2
 * Time: 16:42
 */
namespace common\models;

use Yii;
use yii\db\ActiveRecord;

class GoodsListEdit extends ActiveRecord{

    public static function tableName(){
        return '{{%goods_list_edit}}';
    }

    public function getGoodsListId($goods_id){
        $where = ['goods_id'=>$goods_id];
        $result = $this::find()->where($where)->asArray()->one();
        return $result['id'];
    }
    
    //根据main_goods_id获取主商品列表
    public function getMainGoodsList($main_goods_id){
        if(!empty($main_goods_id)){
            $where = ['use_flg'=>1,'main_goods_id'=>$main_goods_id];
            $main_goods_list = $this::find()->where($where)->asArray()->all();
        }
        if(empty($main_goods_list)){
            $main_goods_list = array();
        }
        return $main_goods_list;
    }
}